# from openpyxl.styles import colors,Font,Alignment
# from openpyxl import Workbook
#
# wb = Workbook()
# ws = wb.active
# # 创建字体对象
# font = Font(name='微软雅黑',size=20,bold=True,italic=True,color='FF0000')
# # 给单元格A1设定内容
# ws['A1'] = 'Hello'
# # 给单元格A1设定样式
# ws['A1'].font = font
# # 保存文件
# wb.save('字体样式.xlsx')


# 设定字体对齐方式
from openpyxl.styles import colors,Font,Alignment
from openpyxl import Workbook

wb = Workbook()
ws = wb.active
# 创建字体对象
font = Font(name='微软雅黑',size=20,bold=True,italic=True,color='FF0000')
# 给单元格A1设定内容
ws['A1'] = 'Hello'
# 给单元格A1设定样式
ws['A1'].font = font

ws['A2'] = 'dfdv'
ws['A2'].alignment = Alignment(horizontal='center',vertical='center')

# 保存文件
wb.save('字体样式.xlsx')